Checks if a variable contains the specified string.
IfInString, var, SearchString
IfNotInString, var, SearchString
Position := InStr(Haystack, Needle [, CaseSensitive?, StartingPos]]) ; See the InStr() function for details.
var | The name of the variable whose contents will be searched for a match. |
SearchString | The string to search for. |
The built-in variables %A_Space% and %A_Tab% contain a single space and a single tab character, respectively, which might be useful when searching for these characters alone.
Another command can appear on the same line as this one. In other words, both of these are equivalent:
IfInString, MyVar, abc, Gosub, Process1 IfInString, MyVar, abc Gosub, Process1
However, items other than named commands are not supported on the same line. For example:
IfInString, MyVar, abc, found := true ; Invalid.
InStr(), RegExMatch(), StringGetPos, IfEqual, if var in/contains MatchList, if var between, if var is type, Blocks, Else
Haystack = abcdefghijklmnopqrs Needle = abc IfInString, Haystack, %Needle% { MsgBox, The string was found. return } else Sleep, 1